package com.xiaodou.mjf.application.core.service.impl;

import java.util.List;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;

import com.xiaodou.mjf.application.core.repository.BankCardRepository;
import com.xiaodou.mjf.application.core.service.BankCardService;
import com.xiaodou.mjf.entity.core.BankCard;
import com.xiaodou.mjf.infrastructure.common.app.JpaSimpleService;


/***
 *
 * BankCard业务访问实现
 * @author XiaoDou.com Code Generator
 * @version 1.0
 * 2014-10-29 17:37:52
 *
 */
@Service @Transactional
public class BankCardServiceImpl extends JpaSimpleService<BankCard,String> implements BankCardService{

	Logger logger = LoggerFactory.getLogger(BankCardServiceImpl.class);

    @Resource
    BankCardRepository bankCardRepository;

    @Override
    protected JpaRepository<BankCard, String> getRepository() {
        return bankCardRepository;
    }

//    @Override
//	public List<BankCard> list(BankCard bankCard) {
//
//    	List<BankCard> bankCards= bankCardRepository.findAll((root,query,cb) -> {
//			
//			Predicate p1 = cb.equal(root.get("memberId").as(String.class),bankCard.getMemberId());
//			Predicate p2 = cb.equal(root.get("status").as(Integer.class),bankCard.getStatus());
//			return query.where(p1,p2).getRestriction();
//	
//		});
//		return bankCards;
//	}
    @Override
	public List<BankCard> list(BankCard bankCard) {

    	List<BankCard> bankCards= bankCardRepository.findByMemberIdandStatus(bankCard.getMemberId(), bankCard.getStatus());
		return bankCards;
	}

	@Override
	public BankCard find(String uid, String cardNo,Integer status) {
		
		return bankCardRepository.find(uid, cardNo,status);
	}

}

